#!/bin/sh
cd $(dirname $0) 
set -e

d=$(mktemp -d in.XXXXXXXXX)
d2=$(mktemp -d out.XXXXXXXX)
cd $d
tar -zxf ../apiconfig.tar.gz
cd ..
cat > recursor.yml << EOF
incoming:
  port: 9999
recursor:
  include_dir: $d
  socket_dir: .
webservice:
  api_dir: $d2
EOF
${PDNSRECURSOR} --config-dir=. &

set +e
for in in 0 1 2 3 4 5 6 7 8 9; do
sleep 1
${RECCONTROL} --config-dir=. quit-nicely
if [ $? = 0 ]; then
  break
fi
done
set -e

diff -u apizones.expected $d2/apizones
diff -u allow-from.yml.expected $d2/allow-from.yml
diff -u allow-notify-from.yml.expected $d2/allow-notify-from.yml
rm -rf $d $d2 recursor.yml
